package com.ruoyi.web.controller.qsng;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.qsng.domain.KClearinghouseCommentReply;
import com.ruoyi.qsng.service.IKClearinghouseCommentReplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 回复Controller
 * 
 * @author gk
 * @date 2023-06-15
 */
@RestController
@RequestMapping("/system/reply")
@Api(tags = "pc--回复Controller")
public class KClearinghouseCommentReplyController extends BaseController
{
    @Autowired
    private IKClearinghouseCommentReplyService kClearinghouseCommentReplyService;

    /**
     * 查询回复列表
     */
    @PreAuthorize("@ss.hasPermi('system:reply:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询回复列表")
    public TableDataInfo list(KClearinghouseCommentReply kClearinghouseCommentReply)
    {
        startPage();
        List<KClearinghouseCommentReply> list = kClearinghouseCommentReplyService.selectKClearinghouseCommentReplyList(kClearinghouseCommentReply);
        return getDataTable(list);
    }

    /**
     * 导出回复列表
     */
    @PreAuthorize("@ss.hasPermi('system:reply:export')")
    @Log(title = "回复", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出回复列表")
    public void export(HttpServletResponse response, KClearinghouseCommentReply kClearinghouseCommentReply)
    {
        List<KClearinghouseCommentReply> list = kClearinghouseCommentReplyService.selectKClearinghouseCommentReplyList(kClearinghouseCommentReply);
        ExcelUtil<KClearinghouseCommentReply> util = new ExcelUtil<KClearinghouseCommentReply>(KClearinghouseCommentReply.class);
        util.exportExcel(response, list, "回复数据");
    }

    /**
     * 获取回复详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:reply:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取回复详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(kClearinghouseCommentReplyService.selectKClearinghouseCommentReplyById(id));
    }

    /**
     * 新增回复
     */
    @PreAuthorize("@ss.hasPermi('system:reply:add')")
    @Log(title = "回复", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增回复")
    public AjaxResult add(@RequestBody KClearinghouseCommentReply kClearinghouseCommentReply)
    {
        return toAjax(kClearinghouseCommentReplyService.insertKClearinghouseCommentReply(kClearinghouseCommentReply));
    }

    /**
     * 修改回复
     */
    @PreAuthorize("@ss.hasPermi('system:reply:edit')")
    @Log(title = "回复", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改回复")
    public AjaxResult edit(@RequestBody KClearinghouseCommentReply kClearinghouseCommentReply)
    {
        return toAjax(kClearinghouseCommentReplyService.updateKClearinghouseCommentReply(kClearinghouseCommentReply));
    }

    /**
     * 删除回复
     */
    @PreAuthorize("@ss.hasPermi('system:reply:remove')")
    @Log(title = "回复", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation(value = "删除回复")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(kClearinghouseCommentReplyService.deleteKClearinghouseCommentReplyByIds(ids));
    }
}
